package view;

import server.Rule;
import server.RulesTableType;
import controller.FirewallSession;

/**
 * Class is responsible for rule add frame.
 * Frame contains all elements that are defined in inherited class.
 */
public class RuleAddFrame extends AbstractRuleEditTable
{
	/**
	 * Serial version ID - for serialization
	 */
	private static final long serialVersionUID = -9005665545823599377L;
	
	/**
	 * C'tor
	 * Define the frame
	 */
	public RuleAddFrame(FirewallSession UI)
	{
	    super("Add rule", UI);
		directionRadio[0].setSelected(true);

		setLocationRelativeTo(null);
		setLocationRelativeTo(null);
	}
	
	/**
	 * @return the table title.
	 */
	protected String getTableLabel()
	{
		return "Add rule:";
	}

	/**
	 * Action performed by finish button press with rule.
	 * @param new_rule - the rule inserted to the table
	 * @param ruleType - the rule type (IN/OUT)
	 */	
	protected void ruleTreatment(RulesTableType ruleType, Rule new_rule)
	{
		switch(ruleType)
		{
		case IN:
			RulesAdvancedTable.currentInRulesTable.addRule(ruleType, new_rule);
			break;
		case OUT:
			RulesAdvancedTable.currentOutRulesTable.addRule(ruleType, new_rule);
			break;			
		}
	
	}
}
